const information = document.getElementById('info')
console.log('versions', versions);
information.innerText = `本应用正在使用 Chrome (v${versions.chrome}), Node.js (v${versions.node}), 和 Electron (v${versions.electron})`




const setButton = document.getElementById('btn')
const titleInput = document.getElementById('title')
setButton.addEventListener('click', () => {
  const title = titleInput.value
  window.electron.setTitle(title)
})

const btn = document.getElementById('btn1')
const filePathElement = document.getElementById('filePath')

btn.addEventListener('click', async () => {
  const filePath = await window.electron.openFile()
  filePathElement.innerText = filePath
})

const counter = document.getElementById('counter')
window.electron.onUpdateCounter((value) => {
  const oldValue = Number(counter.innerText)
  const newValue = oldValue + value
  counter.innerText = newValue.toString()
  window.electron.counterValue(newValue)
})